<template >
    <div>
        <p>我是从首页获取的{{this.$store.state.count}}</p>
        <p>我是从getters获得的计算的值{{this.$store.getters.getStateCount}}</p>
        <p>count的值:{{this.$store.state.count}}</p>
        <button @click="clickFun('+')">+</button>
        <button  @click="clickFun('-')">-</button>
        <div style="border:1px solid red;margin-top:40px;">
            {{count1}}
        </div>
    </div>
</template>
<script>
import {mapState,mapActions,mapGetters} from 'vuex';
export default{
    data(){
        return{

        }
    },
    computed:{
        ...mapState({
            count1:state=>state.count
        })
    },
    methods:{
        clickFun(type){
            if(type=='+'){
                this.$store.dispatch('addFun');
                //this.$store.commit('add')
            }else{
                var n = 5;
                this.$store.dispatch('reductionFun',n);
                //this.$store.dispatch('reductionFun');
                //this.$store.commit('reduction')
            }
            
        }
    }
}
    
</script>